Sometimes, we need to get a resource from the Android resource library without knowing its name. Perhaps we have R.id.data1
through R.id.data9
and want to fetch all 9 of them without hardcoding each one.
This has been possible since API 1, through the use of getIdentifier()
. I will start off by saying that this is not as efficient as referencing R
, so it should be used ONLY in the event that you cannot be sure of the ID you are fetching.